import axios from './axios.js';

export default {
    namespaced:true,
    state: {
        username: ''
    },
    actions:{
        /**
         * 查询案件类型
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async basicsApi({commit, state}, params) {
            try {
                let {data} = await axios.post('/api/cases/basics',params);
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        }, 
		/**
         * 查询案件类型
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async caseTypeApi({commit, state}, params) {
            try {
                let {data} = await axios.get('/api/account/case/type',{params});
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        }, 
		/**
         * 查询律师列表
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async lawyerListApi({commit, state}, params) {
            try {
                let {data} = await axios.get('/api/account/lawyer_certification/list',{params});
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
        /**
         * 删除案件
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async delCaseApi({commit, state}, params) {
            try {
                let {data} = await axios.delete('/api/account/lawyer_case/delete',params);
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
        /**
         * 添加案件
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async addCaseApi({commit, state}, params) {
            try {
                let {data} = await axios.post('/api/account/lawyer_case/insert',params);
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        }, 
		/**
         * 查询某个案例信息
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async queryOneApi({commit, state}, params) {
            try {
                let {data} = await axios.get('/api/account/lawyer_case/query_one',{params});
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
		/**
         * 编辑案件
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async updateCaseApi({commit, state}, params) {
            try {
                let {data} = await axios.put('/api/account/lawyer_case/update',params);
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
        /**
         * 我的案件
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async lawyerCaseApi({commit, state}, params) {
            try {
                let {data} = await axios.get('/api/account/lawyer_case/query_lawyer',{params});
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
		
		
		/**
		 * 诉讼页面(获取诉讼基础数据)
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async getLitiGationApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/cases/litigation',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 提交诉讼(提交案件)
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async litiGationApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/litigation',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 取消诉讼(在用户付款前皆可取消)
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async cancelApi({commit, state}, params) {
		    try {
		        let {data} = await axios.delete('/api/cases/litigation/cancel',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 评论案件
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async commentApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/litigation/comment',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询诉讼详情
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async detailsApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/cases/litigation/details',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 获取用户诉讼列表
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async getListApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/litigation/list',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		
		
		/**
		 * 律师端获取空闲展位位置
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async todoListApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/account/publicity_lawyer/todo_list',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 新增律师展位订单
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async insertLawyerApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/publicity_lawyer_order/insert',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询律师展位订单列表
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async listLawyerApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/publicity_lawyer_order/list',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		
		/**
		 * 待我接受的案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async myCaseOkApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/cases/case/my',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 接受案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async acceptCaseApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/cases/case/accept',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 我的案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async myCaseApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/case/my',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 案源确认
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async confirmCaseApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/cases/case/confirm/${params.case_id}`);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 放弃案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async cancelCaseApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/cases/case/cancel/${params.case_id}`);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 拒绝案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async refuseCaseApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/cases/case/refuse/${params.push_id}`);		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		
		/**
		 * 拒绝案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async new1Api({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/account/publicity_lawyer_history/past');		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 拒绝案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async new2Api({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/account/publicity_lawyer_history/now');		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 拒绝案源
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async new3Api({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/account/publicity_lawyer_history/todo_list',{params});		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 新增所属律所认证审核记录
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async lawFirmApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/user_lawyer_history/law_firm?lawFirmId=' + params.lawFirmId + '&userId=' + params.userId);		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 律师累计收入
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async totalIncomeApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/case/income/total',{params});		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 律师收入明细列表
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async lawyerIncomeApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/case/lawyer/income',params);		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 用户上传案件资料
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async uploadsApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/litigation/uploads',params);		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 律师上传案件资料
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async caseUploadApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/cases/case/upload',params);		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询该律所在职律师
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async userLawyerApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/account/user/lawyer',{params});		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 该律所在职律师离职
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async delLawyerApi({commit, state}, params) {
		    try {
		        let {data} = await axios.put(`/api/account/user/lawyer/${params.user_id}`);		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询诉讼详情
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async caseDetailsApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/cases/case/details',{params});		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 获取该案件合同签署状态
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async caseSignApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/user_sign_flows/case/sign/${params.case_id}`);		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 获取签署地址用于签署
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async signFlowsApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/user_sign_flows/execute/${params.user_id}`,{params});		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 获取签署合同
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async downFlowsApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/account/file/download',{params});		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		// /**
		//  * 切换律所
		//  * @param commit
		//  * @param state
		//  * @param params 请求参数
		//  * @return {Promise<*[e, data]>} e错误信息，data数据
		//  */
		// async lawfirmsApi({commit, state}, params) {
		//     try {
		//         let {data} = await axios.get('/api/account/file/download',{params});		        
		// 		return [null, data]
		//     } catch (e) {
		//         return [e, null]
		//     }
		// },
	}
}